package com.jeesite.modules.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author lihanbing
 * @date 2023/5/18
 * @apiNote
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer result;
    private String message;
    private Object data;

    public static Result buildSuccessResult(){
        return buildSuccessResult(null);
    }
    public static Result buildSuccessResult(Object data){
        return buildSuccessResult("成功",data);
    }
    public static Result buildSuccessResult(String message, Object data){
        Result result = new Result();
        result.setResult(200);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result buildFailureResult(String message){
        Result result = new Result();
        result.setResult(201);
        result.setMessage(message);
        return result;
    }

    public static Result buildFailureResult(String message,Integer errorStatus){
        Result result = new Result();
        result.setResult(errorStatus);
        result.setMessage(message);
        return result;
    }
}
